#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include<string.h>
#include<math.h>
int main() {
    char arr[10];
    unsigned int val = 0;
    int temp = 0;
    while (scanf("%s", arr) != EOF)
    {

        int len = strlen(arr);
        for (int i = 2; i < len; i++)
        {
            if (arr[i] >= 'a' && arr[i] <= 'f')
            {
                temp = arr[i] - 'a' + 10;
            }
            else if (arr[i] >= 'A' && arr[i] <= 'F')
            {
                temp = arr[i] - 'A' + 10;
            }
            else if (arr[i] >= '0' && arr[i] <= '9')
            {
                temp = arr[i] - '0';
            }
            val += temp * (int)pow(16, len - i - 1);
        }
        printf("%u", val);
        return 0;
    }
}